package com.sskj.aikeeper.http;


import com.lzy.okgo.OkGo;
import com.lzy.okgo.request.GetRequest;
import com.lzy.okgo.request.PostRequest;
import com.sskj.aikeeper.bean.BannerNoticeBean;
import com.sskj.aikeeper.bean.CetificationBean;
import com.sskj.aikeeper.bean.CoinDescribeBean;
import com.sskj.aikeeper.bean.HangqingBean;
import com.sskj.aikeeper.bean.HeadBean;
import com.sskj.aikeeper.bean.NoticeListBean;
import com.sskj.aikeeper.bean.ShareBean;
import com.sskj.aikeeper.bean.SignStatusBean;
import com.sskj.aikeeper.bean.Stock;
import com.sskj.common.base.HttpData;
import com.sskj.lib.bean.AppVersionBean;
import com.sskj.lib.bean.BorrowMoneyRecordBean;
import com.sskj.lib.bean.CoinBean;
import com.sskj.lib.bean.CurrentTreasureBean;
import com.sskj.lib.bean.FrashBean;
import com.sskj.lib.bean.HeaderBean;
import com.sskj.lib.bean.HotBean;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.bean.SignInListBean;
import com.sskj.lib.bean.StockBean;
import com.sskj.lib.bean.TextDetailsBean;
import com.sskj.lib.http.HttpConfig;

import java.io.File;
import java.util.List;

/**
 * 作者 :吕志豪
 * 简书：https://www.jianshu.com/u/6e525b929aac
 * github：https://github.com/lvzhihao100
 * 描述：
 * 创建时间：2018-10-15 14:08
 */
public class HttpService {


    /**
     * 实名认证@
     *
     * @param img1 图片1
     * @param img2 图片2
     * @param img3 图片3
     * @param img4 图片4
     * @return
     */
    public PostRequest<HttpData> homeUsersSetAut(String img1, String img2, String img3, String img4) {
        return OkGo.<HttpData>post(com.sskj.lib.http.HttpConfig.BASE_URL + HttpConfig.HOME_USERS_SET_AUT)
                .params("img1", img1)
                .params("img2", img2)
                .params("img3", img3)
                .params("img4", img4)
                ;
    }


    /**
     * 签到
     *
     * @param p
     * @param size
     * @return
     */
    public PostRequest<HttpData<HotBean>> getHotList(String p, String size) {
        return OkGo.<HttpData<HotBean>>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.COMMUNITY_HOT_LIST)
                .params("p", p)
                .params("size", size);
    }

    /**
     * 登录
     *
     * @param username 用户名
     * @param pwd      密码
     * @return
     */
    public PostRequest<HttpData<HeaderBean>> login(String username, String pwd) {
        return OkGo.<HttpData<HeaderBean>>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.LOGIN)
                .params("mobile", username)
                .params("opwd", pwd);
    }

    /**
     * 活期宝数据
     *
     * @param type 类型
     * @return
     */
    public PostRequest<HttpData<CurrentTreasureBean>> getCurrentTreasureData(String type) {
        return OkGo.<HttpData<CurrentTreasureBean>>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.CURRENT_TREASURE)
                .params("type", type);
    }

    /**
     * @param number
     * @param type
     * @return
     */
    public PostRequest<HttpData> getShiftToData(String type, String ptype) {
        return OkGo.<HttpData>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.FUNCTIONS_SHIFT_BALANCE)
                .params("type", type)
                .params("ptype", ptype);
    }

    public PostRequest<HttpData> shiftToMoney(String type, String price, String pwd) {
        return OkGo.<HttpData>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.FUNCTIONS_SHIFT_TO_MONEY)
                .params("type", type)
                .params("price", price)
                .params("pwd", pwd);
    }

    /**
     * 签到状态
     *
     * @param
     * @return
     */
    public PostRequest<HttpData<SignStatusBean>> getSignInState() {
        return OkGo.<HttpData<SignStatusBean>>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.SIGN_IN_STATE);
    }

    /**
     * 签到
     *
     * @param p
     * @param size
     * @return
     */
    public PostRequest<HttpData<SignInListBean>> getSignInList(int p, int size) {
        return OkGo.<HttpData<SignInListBean>>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.SIGN_IN_LIST)
                .params("p", p)
                .params("size", size);
    }

    /**
     * 借币生息记录
     *
     * @return
     */
    public PostRequest<HttpData<BorrowMoneyRecordBean>> getJbsxList(String type, String page, String size) {
        return OkGo.<HttpData<BorrowMoneyRecordBean>>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.FUNCTIONS_BorrowMoneyRecord)
                .params("type", type)
                .params("page", page)
                .params("size", size);
    }

    /**
     * 闪兑记录
     *
     * @return
     */
    public PostRequest<HttpData<FrashBean>> getFrashList() {
        return OkGo.<HttpData<FrashBean>>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.FUNCTIONS_FRASH);
    }

    /**
     * 点击签到
     *
     * @return
     */
    public PostRequest<HttpData> clickSignIn() {
        return OkGo.<HttpData>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.CLICK_SIGN_IN);
    }

    /**
     * 找回密码
     *
     * @param number        手机号
     * @param loginPassword 登录密码
     * @param nextPassword  确认密码
     * @param code          验证码
     * @return
     */
    public PostRequest<HttpData> forgetPassword(String number, String loginPassword, String nextPassword, String code) {
        return OkGo.<HttpData>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.FORGET_PASSWORD)
                .params("mobile", number)
                .params("opwd", loginPassword)
                .params("opwd1", nextPassword)
                .params("code", code);
    }

    public PostRequest<HttpData<TextDetailsBean>> getTextDetails(String msg_id) {
        return OkGo.<HttpData<TextDetailsBean>>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.COMMUNITY_TEXT_DETAILS)
                .params("msg_id", msg_id);
    }

    /**
     * 发表文章
     *
     * @param title   标题
     * @param content 文章
     * @return
     */
    public PostRequest<HttpData> setTextSubmit(String title, String content) {
        return OkGo.<HttpData>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.COMMUNITY_SUBMIT_TEXT)
                .params("title", title)
                .params("content", content);
    }

    /**
     * 获取验证码
     *
     * @param number
     * @param type
     * @return
     */
    public PostRequest<HttpData> getCode(String number, String type) {
        return OkGo.<HttpData>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.GET_CODE)
                .params("mobile", number)
                .params("type", type);
    }

    /**
     * 注册
     *
     * @param yq     邀请码
     * @param number 手机号
     * @param code   验证码
     * @param pwd    密码
     * @param tpwd   资金密码
     * @return
     */
    public PostRequest<HttpData> register(String yq, String number, String code, String pwd, String tpwd) {
        return OkGo.<HttpData>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.REGISTER)
                .params("tjuser", yq)
                .params("mobile", number)
                .params("code", code)
                .params("opwd", pwd)
                .params("tpwd", tpwd);
    }

    /**
     * 设置头像
     *
     * @param head 头像文件
     * @return
     */
    public PostRequest<HttpData<HeadBean>> uploadHead(File head) {
        return OkGo.<HttpData<HeadBean>>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.UPLOAD_HEAD)
                .params("upic", head);
    }

    /**
     * 设置昵称
     *
     * @param nickname
     * @return
     */
    public PostRequest<HttpData> setNickName(String nickname) {
        return OkGo.<HttpData>post(com.sskj.lib.http.HttpConfig.BASE_URL + com.sskj.lib.http.HttpConfig.SET_NICKNAME)
                .params("nickname", nickname);
    }

    /**
     * 身份认证状态
     *
     * @return
     */
    public PostRequest<HttpData<CetificationBean>> getCertificationStatus() {
        return OkGo.post(com.sskj.lib.http.HttpConfig.BASE_URL + HttpConfig.CERTIFICATION_STATUS);
    }

    /**
     * 身份认证
     *
     * @param realname
     * @param idCard
     * @param handImg
     * @param fontImg
     * @param backImg
     * @return
     */
    public PostRequest<HttpData> setRenzheng(String realname, String idCard, File handImg, File fontImg, File backImg) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.RENZHENG)
                .params("realname", realname)
                .params("idcard", idCard)
                .params("cardimg1", handImg)
                .params("cardimg2", fontImg)
                .params("cardimg3", backImg);
    }

    /**
     * 消息中心
     *
     * @param page
     * @param size
     * @return
     */
    public PostRequest<HttpData<PageBean<NoticeListBean>>> getNoticeList(int page, int size) {
        return OkGo.<HttpData<PageBean<NoticeListBean>>>post(HttpConfig.BASE_URL + HttpConfig.NOTICE_LIST)
                .params("page", page)
                .params("size", size);
    }

    /**
     * 获取通知消息
     *
     * @param page
     * @param size
     * @return
     */
    public PostRequest<HttpData<PageBean<NoticeListBean>>> getNoticeList(long time, int page, int size) {
        return OkGo.<HttpData<PageBean<NoticeListBean>>>post(HttpConfig.BASE_URL + HttpConfig.NOTICE_LIST)
                .params("time", time)
                .params("page", page)
                .params("size", size);
    }

    /**
     * 分享 生成APP下载二维码
     *
     * @return
     */
    public PostRequest<HttpData<ShareBean>> getShareInfo() {
        return OkGo.post(HttpConfig.BASE_URL + HttpConfig.SHARE_INFO);
    }

    public PostRequest<HttpData<BannerNoticeBean>> getTopData() {
        return OkGo.post(HttpConfig.BASE_URL + HttpConfig.BANNER_NOTICE_LIST);
    }

    /**
     * 行情列表
     *
     * @return
     */
    public GetRequest<HttpData<List<CoinBean>>> getHangqingData(String mark) {
        return OkGo.<HttpData<List<CoinBean>>>get(HttpConfig.BASE_URL + HttpConfig.HANGQING)
                .params("mark", mark);
    }

    /**
     * 币种信息
     *
     * @param coinCode
     * @return
     */
    public GetRequest<HttpData<CoinDescribeBean>> getCoinDescribe(String coinCode) {
        return OkGo.<HttpData<CoinDescribeBean>>get(HttpConfig.BASE_URL + HttpConfig.COIN_DESCRIBE)
                .params("code", coinCode);
    }

    public GetRequest<HttpData<List<Stock>>> getStockInfo(String coinGoods, String coinCode) {
        return OkGo.<HttpData<List<Stock>>>get(HttpConfig.BASE_URL + HttpConfig.STOCK_INFO)
                .params("goodsType", coinGoods)
                .params("code", coinCode);
    }

    /**
     * 版本管理
     *
     * @param versionCode
     * @return
     */
    public PostRequest<HttpData<AppVersionBean>> checkVersion(String versionCode) {
        return OkGo.<HttpData<AppVersionBean>>post(HttpConfig.BASE_URL + HttpConfig.CHECK_VERSION)
                .params("version", versionCode)
                .params("type", 1);
    }

    public PostRequest<HttpData> changePayPwd(String mobile, String tpwd, String tpwd1, String code) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.CHANGE_PAY_PWD)
                .params("mobile", mobile)
                .params("tpwd", tpwd)
                .params("tpwd1", tpwd1)
                .params("code", code);
    }

    /**
     * 忘记密码 修改登录密码
     *
     * @param oldPwd
     * @param newPwd
     * @param confirmPwd
     * @return
     */
    public PostRequest<HttpData> changeLoginPwd(String mobile, String oldPwd, String newPwd, String confirmPwd) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.CHANGE_LOGIN_PWD)
                .params("mobile", mobile)
                .params("oldpwd", oldPwd)
                .params("opwd", newPwd)
                .params("opwd1", confirmPwd);
    }
}